/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package koor.entity;

import java.sql.Date;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.persistence.*;

/**
 *
 * @author Admin
 */
@Entity
@Table(name = "course_work")
public class CourseWork extends AbstractEntity{
    
    @Column(name = "theme")
    private String theme;
    
    @ManyToOne
    @JoinColumn(name = "student_id")
    private Student author;
    
    @ManyToOne
    @JoinColumn(name = "teacher_id")
    private Teacher leader;
    
    @ManyToOne
    @JoinColumn(name = "subject_id")
    private Subject subject;
    
    @Column(name = "consultant")
    private String consultant;
    
    @Column(name = "direction")
    private String direction;
    
    @Column(name = "mark")
    private int mark;
    
    @Column(name = "date_of_protection")
    private Date date;
    
    @OneToOne
    @JoinColumn(name = "text_id")
    private Text text;
    
    @Column(name = "placement")
    private String placement;
    
    @Column(name = "inventory_number")
    private String inventoryNumber;
    
    @ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
    @JoinTable(name = "committee", joinColumns = { @JoinColumn(name = "course_work_id") }, 
            inverseJoinColumns = { @JoinColumn(name = "teacher_id") })
    private Set<Teacher> committee = new LinkedHashSet<Teacher>();
    
    @ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
    @JoinTable(name = "course_work_tag", joinColumns = { @JoinColumn(name = "course_work_id") }, 
            inverseJoinColumns = { @JoinColumn(name = "tag_id") })
    private Set<Tag> tags = new LinkedHashSet<Tag>();

    public CourseWork() {
    }

    public CourseWork(int id) {
        super(id);
    }

    public Student getAuthor() {
        return author;
    }

    public void setAuthor(Student author) {
        this.author = author;
    }

    public Set<Teacher> getCommittee() {
        return committee;
    }

    public void setCommittee(Set<Teacher> committee) {
        this.committee = committee;
    }

    public String getConsultant() {
        return consultant;
    }

    public void setConsultant(String consultant) {
        this.consultant = consultant;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getDirection() {
        return direction;
    }

    public void setDirection(String direction) {
        this.direction = direction;
    }

    public String getInventoryNumber() {
        return inventoryNumber;
    }

    public void setInventoryNumber(String inventoryNumber) {
        this.inventoryNumber = inventoryNumber;
    }

    public Teacher getLeader() {
        return leader;
    }

    public void setLeader(Teacher leader) {
        this.leader = leader;
    }

    public int getMark() {
        return mark;
    }

    public void setMark(int mark) {
        this.mark = mark;
    }

    public String getPlacement() {
        return placement;
    }

    public void setPlacement(String placement) {
        this.placement = placement;
    }

    public Subject getSubject() {
        return subject;
    }

    public void setSubject(Subject subject) {
        this.subject = subject;
    }

    public Set<Tag> getTags() {
        return tags;
    }

    public void setTags(Set<Tag> tags) {
        this.tags = tags;
    }

    public Text getText() {
        return text;
    }

    public void setText(Text text) {
        this.text = text;
    }

    public String getTheme() {
        return theme;
    }

    public void setTheme(String theme) {
        this.theme = theme;
    }

}
